import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LayoutView from '../views/Layout.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/RegisterView.vue')
  },
  {
    path: '/reset',
    name: 'reset',
    component: () => import('../views/ResetPassword.vue')
  },
  {
    path: '/',
    name: 'Layout',
    // component: LayoutView,
    component:() =>import('../views/Layout.vue'),
    children: [
      {
        path: '',
        name: 'home',
        component: HomeView
      },
      {
        path: 'admin',
        name: 'admin',
        component: () => import('../views/AdminView.vue')
      },
      {
        path: 'tutor',
        name: 'tutor',
        component: () => import('../views/TutorView.vue')
      },
      {
        path: 'type',
        name: 'type',
        component: () => import('../views/TypeView.vue')
      },
      {
        path: 'hire',
        name: 'hire',
        component: () => import('../views/HireView.vue')
      },
      {
        path: 'communicate',
        name: 'communicate',
        component: () => import('../views/Communication.vue')
      },
      {
        path: 'log',
        name: 'log',
        component: () => import('../views/LogView.vue')
      },
      {
        path: 'notice',
        name: 'notice',
        component: () => import('../views/NoticeView.vue')
      },
      {
        path: 'chat',
        name: 'chat',
        component: () => import('../views/Im.vue')
      },
      {
        path: 'common',
        name: 'common',
        component: () => import('../views/Common.vue')
      },
      {
        path: 'live',
        name: 'live',
        component: () => import('../views/Live.vue')
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('../views/User.vue')
      },
      {
        path: 'apply',
        name: 'apply',
        component: () => import('../views/Apply.vue')
      }
    ]
  },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

//路由守卫
// router.beforeEach((to, from, next)=>{
 
//   const user = localStorage.getItem("user");
//   if(!user && (to.path!=='/login') &&(to.path != '/register') && (to.path != '/reset')){
//     return next('/login');
//   }
//   next()
// })



export default router
